<?php namespace web\admin\controller;

use hdphp\route\Controller;

/*class Login extends Controller{
    private $db;
    public function __construct(){
        $this->db = new \system\model\User();
    }
    public function index(){
        if(IS_POST){
            if($this->db->login()){
              //登录成功
                message('操作成功',U('index.index'),'success');
            }
            message($this->db->getError(),'back','error');
        }
        //载入模板
        View::make();
    }
    //验证码
    public function code(){
        Code::num(1)->make();
    }

    //退出
    public function out(){
        session_unset();
        session_destroy();
        go('index');
    }

}
*/
class Login extends Controller{
    //定义私有属性
    private $db;
    public function __construct(){
        $this->db = new \system\model\User();
    }
    public function index(){
        if(IS_POST){
            if($this->db->login()){
                //登录成功提示
                message('操作成功',U('index.index'),'success');
            }
            message($this->db->getError(),'back','error');
        }
        //载入模板
        View::make();
    }
    //显示验证码
    public function code(){
        Code::num(4)->make();
    }
    //退出登录
    public function out(){
        session_unset();
        session_destroy();
        go('index');
    }
}